package com.zdb.n1.controller;

import com.zdb.n1.payload.response.RankingResponse;
import com.zdb.n1.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/statistics")
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    @GetMapping("/rankings")
    public ResponseEntity<List<RankingResponse>> getRankings(
            @RequestParam(defaultValue = "DURATION") String type,
            @RequestParam(defaultValue = "10") int limit,
            @RequestParam(defaultValue = "MONTH") String timeRange) {
        
        return ResponseEntity.ok(statisticsService.getRankings(type, limit, timeRange));
    }
} 